<?php
/*This is ajax file for saving result in draft*/
require_once "includes/config.php";

$chat_status    = $_REQUEST['chat_status'];
$user_id        = $_REQUEST['user_id'];
$selUsr=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='$user_id'"));

    if($chat_status=='0')
	{
				$subject="Your chatting option has been turned off successfully";
				$message="Dear ".$selUsr['first_name']." ".$selUsr['last_name'].",<br><br>
	You have turned off the chatting option, that prevents others from directly contacting you by chat, but you can contact others by chat,  if you choose to do so.  Please keep in mind that you can always log back into My Account under Comm. Options and turn chat on. <br><br>Thank you<br><br>Swapen Team";
			    $headers = "From: Swapen.com<mail@swapen.com> \r\n";
				$headers .= 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
				mail($selUsr['email'],$subject, $message, $headers);
	}
	else if($chat_status=='1')
	{
				$subject="Your chatting option has been turned on successfully";
				$message="Dear ".$selUsr['first_name']." ".$selUsr['last_name'].",<br><br>
	You have turned on the chatting option, and now they can directly contact you by chat.  Please keep in mind that you can always log back into My Account under Comm. Options and turn chat off. <br><br>Thank you<br><br>Swapen Team";
			    $headers = "From: Swapen.com<mail@swapen.com> \r\n";
				$headers .= 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
				mail($selUsr['email'],$subject, $message, $headers);
	}
	$qry = mysql_query("update tbl_users set chat_status='$chat_status' where user_id='$user_id'") or die(mysql_error());

?>